<template>
  <div>
    <OcrUpload v-bind="$attrs" @change="imgChange" />
    <fks-input
      style="margin-top: 16px"
      type="textarea"
      v-bind="$attrs"
      :rows="3"
      :value="value"
      @input="$emit('input', $event)"
    >
    </fks-input>
  </div>
</template>

<script>
import OcrUpload from './ocrUpload.vue'
export default {
  name: 'ocr',
  components: {
    OcrUpload
  },
  props: {
    value: {
      type: String,
      default: ''
    }
  },
  methods: {
    imgChange(res) {
      let text = ''
      let result = res.data[0]
      result.forEach((item) => {
        text += item.text + '\n'
      })
      let maxlength = this.$attrs.maxlength
      text = text.substr(0, maxlength)
      this.$emit('input', text)
      // console.log(res)
    }
  }
}
</script>

<style></style>
